#include<bits/stdc++.h>
using namespace std;
int n,a[200010],c[200010],d[200010];
map<int,int>b;
int main(){
	freopen("color.in","r",stdin);
	freopen("color.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(b[a[i]]==0)c[i]++;
		b[a[i]]++,c[i]+=c[i-1],d[i]=i-c[i];
	}
	cout<<d[n]-1;
    return 0;
}
